# _*_ encoding: utf-8 _*_
from spider import BulletChatSpider
from spider import BulletChatSpiderO
from spider import FansSpider
from spider import VideoInfoSpider

class BilibiliApp(object):
    def __init__(self, **kwargs):
        '''
        vmid： up主ID
        bvid: 视频BVID
        mode: 使用爬取弹幕接口，默认`旧接口`
        '''
        self.mode = kwargs.get("mode") or False
        self.bvid = kwargs.get("bvid")
        self.vmid = kwargs.get("vmid")


    def bulletChat(self) -> None:
        if self.mode == True:
            '''使用新接口'''
            BulletChatSpider(self.bvid).loop()
        else:
            '''使用旧接口'''
            BulletChatSpiderO(self.bvid).loop()
        return

    def fansAndFollows(self) -> None:
        '''粉丝和关注数'''
        FansSpider(self.vmid).getFansAndfollows().print()
        return


    def vidieInfo(self):
        '''UP主所有视频信息'''
        VideoInfoSpider(self.vmid).loop()

    def run(self) -> None:
        '''运行'''
        if self.bvid is not None:
            self.bulletChat()

        if self.vmid is not None:
            self.fansAndFollows()

        if self.vmid is not None:
            self.vidieInfo()

        return